package com.ruoyi.car.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.car.domain.OnlineCarOrders;
import com.ruoyi.car.service.IOnlineCarOrdersService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 网约车订单Controller
 * 
 * @author Jolia
 * @date 2023-06-20
 */
@RestController
@RequestMapping("/orders")
public class OnlineCarOrdersController extends BaseController
{
    @Autowired
    private IOnlineCarOrdersService onlineCarOrdersService;

    /**
     * 查询网约车订单列表
     */
    @RequiresPermissions("car:orders:list")
    @GetMapping("/list")
    public TableDataInfo list(OnlineCarOrders onlineCarOrders)
    {
        startPage();
        List<OnlineCarOrders> list = onlineCarOrdersService.selectOnlineCarOrdersList(onlineCarOrders);
        return getDataTable(list);
    }

    /**
     * 导出网约车订单列表
     */
    @RequiresPermissions("car:orders:export")
    @Log(title = "网约车订单", businessType = BusinessType.EXPORT)
    public void export(HttpServletResponse response, OnlineCarOrders onlineCarOrders)
    {
        List<OnlineCarOrders> list = onlineCarOrdersService.selectOnlineCarOrdersList(onlineCarOrders);
        ExcelUtil<OnlineCarOrders> util = new ExcelUtil<OnlineCarOrders>(OnlineCarOrders.class);
        util.exportExcel(response, list, "网约车订单数据");
    }

    /**
     * 获取网约车订单详细信息
     */
    @RequiresPermissions("car:orders:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(onlineCarOrdersService.selectOnlineCarOrdersById(id));
    }

    /**
     * 新增网约车订单
     */
    @RequiresPermissions("car:orders:add")
    @Log(title = "网约车订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OnlineCarOrders onlineCarOrders)
    {
        return toAjax(onlineCarOrdersService.insertOnlineCarOrders(onlineCarOrders));
    }

    /**
     * 修改网约车订单
     */
    @RequiresPermissions("car:orders:edit")
    @Log(title = "网约车订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OnlineCarOrders onlineCarOrders)
    {
        return toAjax(onlineCarOrdersService.updateOnlineCarOrders(onlineCarOrders));
    }

    /**
     * 删除网约车订单
     */
    @RequiresPermissions("car:orders:remove")
    @Log(title = "网约车订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(onlineCarOrdersService.deleteOnlineCarOrdersByIds(ids));
    }
}
